package aiyh.utils.zwl.common.logging;


/**
 * 日志工厂类
 * 
 * @author zwl
 * @date 2020-03-10
 * @version 1.0
 */
public class LoggerFactory {
    private static final String loggerName = "cus";

    public static Logger getLogger(String LogName, String clazz) {
        if("".equals(LogName)) {
            LogName = loggerName;
        }
        Logger logger = new Log4JLogger();
        logger.setClassname(clazz);
        logger.init(LogName);
        return logger;
    }

    /**
     * 获取指定类的logger对象
     * @param clazz 类
     * @return 日志对象
     */
    public static Logger getLogger(Class<?> clazz) {
        return getLogger(loggerName,clazz.getCanonicalName());
    }
    
    /**
     * 获取指定类的logger对象
     * @param className 类名
     * @return 日志对象
     */
    public static Logger getLogger(String className) {
        return getLogger(loggerName,className);
    }
    /**
     * 获取未指定指定类的logger对象
     * @return 日志对象
     */
    public static Logger getLogger() {
        String className = Thread.currentThread().getStackTrace()[2].getClassName();
        return getLogger(loggerName, className);
    }
}
